# $Id$
#

PATH="/sbin:/usr/sbin:/usr/bin:/bin:/etc/scripts:/lib/dsktool/bin:."
TERM=linux
PS1="["`tty`"] [\h]:# "
PS2="> "
HOME=/root
export PATH DISPLAY TERM PS1 PS2 MANPATH HOME

umask 022

# common.disks.fn:verify
export DISKS_DONE=

. /lib/dsktool/conf/env
. /lib/dsktool/lib/common.fn
. /lib/dsktool/lib/common.disks.fn
. /lib/dsktool/lib/vault.fn
. /lib/dsktool/lib/disk.fn
. /lib/dsktool/lib/lvm.fn
. /lib/dsktool/lib/laststep.fn
. /lib/dsktool/lib/mountpoint.fn
. /lib/dsktool/lib/network.fn
. /lib/dsktool/lib/md.fn
. /lib/dsktool/lib/enclayer.fn
. /lib/dsktool/lib/boot.fn
. /lib/dsktool/lib/scan.fn

# gui
. /lib/dsktool/lib/gui-text-common.fn

. /lib/dsktool/lib/gui/gui.fn
. /lib/dsktool/lib/gui/gcommon.fn
. /lib/dsktool/lib/gui/gcommon.disk.fn
. /lib/dsktool/lib/gui/gdisk.fn
. /lib/dsktool/lib/gui/gmd.fn
. /lib/dsktool/lib/gui/glvm.fn
. /lib/dsktool/lib/gui/glaststep.fn
. /lib/dsktool/lib/gui/genclayer.fn
. /lib/dsktool/lib/gui/gnetwork.fn
. /lib/dsktool/lib/gui/gmountpoint.fn
. /lib/dsktool/lib/gui/gboot.fn
. /lib/dsktool/lib/gui/gaasp.fn

# trap
_chk_err ()
{
	local errcode="\nERR:$1:caller=$(caller 0)"
	echo -e "$errcode" |tee -a $logallfile
	if [ "$interactive_session" = "1" ]; then
		if [ "$(<$disk_commit_switch_running)" = "1" ]; then 
			echo 0 > $disk_commit_switch_running
		fi
		echo -e "\nPress any key to continue."
		read nothing
	fi
	exec /lib/dsktool/bin/shell
}

# dont blank terminal
echo -e "\e[9;0]"

export -f _chk_err
trap - ERR INT DEBUG RETURN
set -o pipefail
set -eTE
trap '_chk_err $? $FUNCNAME $LINENO' ERR

# aasp
if [ ! -f $vp_pass -a "$(< $gui_switch)" = "0" ]; then
	_warn_msg "Must set the vault password before applying changes related to LUKS, call 'aasp' ..."
fi

# alias
alias gui="echo 1 > $gui_switch ; echo 1 > $gui_permanent_switch ; _gui"
alias text="echo 0 > $gui_permanent_switch"

# gui callbacks
# XXX compare to autoinstall.fn
echo 0 > $gui_switch

if [ "${COLUMNS:-1}" -lt "81" -o "$(< $gui_permanent_switch )" = "0" ]; then
	echo -e "\n For changing the keymap type: 'ck'."
	echo -e " For setting the timezone type: 'tz'."
	echo -e " For setting the time type: 'set_time'."
	echo -e " For changing the vault password type: 'aasp'."
	echo -e " For permanent text mode installer type: 'text'"
	echo -e " For gui installer type: 'gui', ( migth not work correctly if your reading this )."
	echo -e " For text installer type: 'help' and fallow instructions.\n\n"
else
	gui
	echo 0 > $gui_switch
fi

# vim: ts=2 syn=sh
# bashrc: end
